package com.woniu.market_stall_web.config;


import com.woniu.market_stall_web.socket.PushHandShakeIntercepter;
import com.woniu.market_stall_web.socket.PushHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

@Configuration
public class WebSocketConfig implements WebSocketConfigurer {

    @Autowired
    PushHandShakeIntercepter pushHandShakeIntercepter ;

    @Autowired
    PushHandler pushHandler ;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {

        webSocketHandlerRegistry.addHandler(pushHandler,"/wspush")
                .addInterceptors(pushHandShakeIntercepter).setAllowedOrigins("*");

    }
}
